package cn.forge.mall.module.member.controller.app.auth;

import cn.forge.mall.framework.common.pojo.CommonResult;
import cn.forge.mall.system.api.oauth2.OAuth2TokenApi;
import cn.forge.mall.system.api.oauth2.dto.OAuth2AccessTokenCheckRespDTO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.annotation.security.PermitAll;

@RestController
@RequestMapping("/member/auth")
@Slf4j
public class AppAuthController {

    @Resource
    private OAuth2TokenApi oAuth2TokenApi;

    @GetMapping("/test/rpc")
    @PermitAll
    public CommonResult<String> test(){
        CommonResult<OAuth2AccessTokenCheckRespDTO> result = oAuth2TokenApi.testRpc("rpc测试");
        System.out.println(result.getCheckedData().getUserId());
        Long userId = result.getCheckedData().getUserId();
        return CommonResult.success(userId!=null ?userId.toString():null);
    }
}
